import {defineStore} from "pinia";
import {ref} from 'vue';

// 全局loading配置
const useLoadingStore = defineStore('loading', () => {
  // 是否展示loading
  const show = ref(false);
  // Spin 的文字信息
  const description = ref("");

  function start(text) {
    if (text) {
      description.value = text;
    }
    show.value = true;
  }

  function stop() {
    show.value = false;
  }

  return {
    show,
    description,
    start,
    stop
  }
})

export default useLoadingStore;
